package com.fuxian.service.impl;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.fuxian.dao.TeacherDao;
import com.fuxian.model.Teacher;
import com.fuxian.model.Teacherlessons;
import com.fuxian.service.TeacherLessonService;
import com.fuxian.service.TeacherService;

@Repository
public class TeacherServiceImpl implements TeacherService {
	@Resource
	private TeacherDao teacherdao;

	@Resource
	private TeacherLessonService teacherLessonService;

	public void addTeacher(Teacher teacher) {
		teacherdao.addTeacher(teacher);

	}

	public void deleteTeacherById(int id) {
		teacherdao.deleteTeacherById(id);
	}

	public void modifyTeacher(Teacher teacher) {
		teacherdao.modifyTeacher(teacher);

	}

	public List<Teacher> selectAllTeacher(int start, int size) {

		return teacherdao.selectAllTeacher(start, size);
	}

	public List<Teacher> selectTeacherByCreatetime(Timestamp create_time,
			int start, int size) {

		return teacherdao.selectTeacherByCreatetime(create_time, start, size);
	}

	public Teacher selectTeacherById(int id) {

		return teacherdao.selectTeacherById(id);
	}

	public List<Teacher> selectTeacherByName(String name) {

		return teacherdao.selectTeacherByName(name);
	}

	public List<Teacher> selectTeacherByEdubg(String edu_bg, int start, int size) {

		return teacherdao.selectTeacherByEdubg(edu_bg, start, size);
	}

	public List<Teacher> selectTeachersByLessonId(int lessonId) {
		// get teacher id by lesson id
		List<Teacherlessons> teacherlessonList = teacherLessonService
				.selectTeacherLessonsByLessonId(lessonId);
		// get teacher info by teacher id
		List<Teacher> teacherList = new ArrayList<Teacher>();
		for (Teacherlessons teacherlesson : teacherlessonList) {
			teacherList.add(teacherdao.selectTeacherById(teacherlesson
					.getTeacher_id()));
		}
		return teacherList;
	}
	
	public int selectCount(){
		return teacherdao.selectTeacherCount();
	}

}
